package com.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.ClienteBean;

public class Clientes extends AbstractAction {

	private static final String INIT_URL					= "/programs/clientes/init.jsp";
	private static final String LIST_URL					= "/programs/clientes/list.jsp";
	private static final String STREET_URL					= "/programs/clientes/streets.jsp?street=";
	
	private static final String INIT_ACTION 				= "init";
	private static final String LIST_ACTION 				= "list";
	private static final String ADD_ACTION 					= "add";
	private static final String REMOVE_ACTION 				= "remove";
	private static final String MODIFY_ACTION 				= "modify";
	private static final String STREET_ACTION 				= "street";
	
	@Override
	public String doAction(HttpServletRequest req, HttpServletResponse res) {
		// TODO Auto-generated method stub
		String action=req.getParameter("action");
		ClienteBean bean=new ClienteBean();
		req.getSession().setAttribute("bean",bean);
		if(INIT_ACTION.equals(action)){
			return INIT_URL;
		}
		if(LIST_ACTION.equals(action)){
			return LIST_URL;
		}
		if(ADD_ACTION.equals(action)){
			bean.add(req);
		}
		if(REMOVE_ACTION.equals(action)){
			bean.remove(req);
		}
		if(MODIFY_ACTION.equals(action)){
			
			
		}
		if(STREET_ACTION.equals(action)){
			String street=null;
			if(req.getParameter("streetName")!=null){
				street=req.getParameter("streetName").toString();
			}
			return STREET_URL+street;
		}
		return null;
	}

}
